home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume9 / acm / part05 < prev    next >
Encoding:
Internet Message Format  |  1990-10-09  |  36.1 KB

  1. Path: uunet!snorkelwacker!apple!netcom!amdcad!sun!mipsdal.mips.com
  2. From: riley@mipsdal.mips.com (Riley Rainey)
  3. Newsgroups: comp.sources.x
  4. Subject: v09i073: acm, X aerial combat simulation, Part05/05
  5. Message-ID: <143452@sun.Eng.Sun.COM>
  6. Date: 7 Oct 90 18:13:26 GMT
  7. References: <csx-09i069:acm@uunet.UU.NET>
  8. Sender: news@sun.Eng.Sun.COM
  9. Lines: 1417
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: riley@mipsdal.mips.com (Riley Rainey)
  13. Posting-number: Volume 9, Issue 73
  14. Archive-name: acm/part05
  15.  
  16. echo x - ./fsim/server.c
  17. sed 's/^X//' >./fsim/server.c <<'*-*-END-of-./fsim/server.c-*-*'
  18. X/*
  19. X *    xflight : an aerial combat simulator for X
  20. X *
  21. X *    Written by Riley Rainey,  riley@mips.com
  22. X *
  23. X *    Permission to use, copy, modify and distribute (without charge) this
  24. X *    software, documentation, images, etc. is granted, provided that this 
  25. X *    comment and the author's name is retained.
  26. X *
  27. X */
  28. X#include "manifest.h"
  29. X#include <sys/types.h>
  30. X#include <stdio.h>
  31. X#include <pwd.h>
  32. X#include <signal.h>
  33. X#include <sys/socket.h>
  34. X#include <sys/ioctl.h>
  35. X#include <sys/time.h>
  36. X#include <netinet/in.h>
  37. X#include <netdb.h>
  38. X#include <setjmp.h>
  39. X
  40. Xextern struct servent *getservent();
  41. Xint sdebug = 1;
  42. Xint listen_socket;
  43. X
  44. Xvoid parseinfo (s, a, b, c)
  45. Xchar *s, *a, *b, *c; {
  46. X
  47. X    char    *p;
  48. X
  49. X    for (p=a; *s; ++s, ++p)
  50. X        if ((*p = *s) == ' ') {
  51. X            *p = '\0';
  52. X            break;
  53. X        }
  54. X
  55. X    ++ s;
  56. X
  57. X    for (p=b; *s; ++s, ++p)
  58. X        if ((*p = *s) == ' ') {
  59. X            *p = '\0';
  60. X            break;
  61. X        }
  62. X
  63. X    ++ s;
  64. X
  65. X    strcpy (c, s);
  66. X
  67. X    return;
  68. X}
  69. X
  70. Xmain (argc, argv)
  71. Xint    argc;
  72. Xchar    *argv[]; {
  73. X
  74. X    struct sockaddr_in sin;
  75. X    struct    servent *sp;
  76. X    int    on = 1;
  77. X    int    i, background = 0;
  78. X
  79. X/*
  80. X *  parse arguments
  81. X */
  82. X
  83. X    for (i=1; i<argc; ++i) {
  84. X
  85. X        if (*argv[i] == '-')
  86. X            switch (*(argv[i]+1)) {
  87. X
  88. X            case 'b':
  89. X                background = 1;
  90. X                break;
  91. X
  92. X            default:
  93. X                fprintf (stderr, "Invalid switch \"%s\"\n", argv[i]);
  94. X                break;
  95. X            }
  96. X    }
  97. X
  98. X    if (sdebug) {
  99. X/*
  100. X        if ((sp = getservbyname ("acm", "tcp");
  101. X            fprintf (stderr, "can't find acm service\n");
  102. X            exit (1);
  103. X        }
  104. X*/
  105. X
  106. X        if ((listen_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
  107. X            perror ("socket");
  108. X            exit (1);
  109. X        }
  110. X
  111. X        sin.sin_family = AF_INET;
  112. X        sin.sin_addr.s_addr = INADDR_ANY;
  113. X        sin.sin_port = htons(ACM_PORT);
  114. X
  115. X        if (bind (listen_socket, &sin, sizeof(sin)) < 0) {
  116. X            perror ("bind");
  117. X            exit (1);
  118. X        }
  119. X    }
  120. X    else {
  121. X        listen_socket = 0;        /* inetd sets this up for us */
  122. X/*        freopen ("/people/riley/acm.error", "a", stderr); */
  123. X    }
  124. X
  125. X        (void) setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR,
  126. X        (char *) &on, sizeof on);
  127. X    (void) setsockopt(listen_socket, SOL_SOCKET, SO_KEEPALIVE,
  128. X        (char *) &on, sizeof on);
  129. X    ioctl(listen_socket, FIONBIO, (char *) &on);
  130. X
  131. X    if (listen (listen_socket, 5) < 0) {
  132. X        perror ("listen");
  133. X        close (listen_socket);
  134. X        exit (1);
  135. X    }
  136. X
  137. X    if (background)
  138. X#ifdef SYSV
  139. X        setpgrp (1);
  140. X#else
  141. X        setpgrp (0, 1);
  142. X#endif
  143. X
  144. X    init ();
  145. X    input();
  146. X
  147. X}
  148. X
  149. Xint peerdied = 0;
  150. X
  151. Xdeadpeer () {
  152. X    fprintf (stderr, "SIGPIPE\n");
  153. X    peerdied = 1;
  154. X}
  155. X
  156. Xstruct    sigvec    alrm, pipe;
  157. Xint doUpdate = 0;
  158. X
  159. Xmyalarm () {
  160. X    doUpdate++;
  161. X    sigvec (SIGALRM, &alrm, (struct sigvec *) 0);
  162. X}
  163. X
  164. Xinput () {
  165. X
  166. X    fd_set    fdset, ofdset;
  167. X    int    nplayers = 0, news = -1, playerchange = 0, n, pno, addrlen;
  168. X    int    on = 1;
  169. X    struct    sockaddr addr;
  170. X    struct    itimerval update;
  171. X    char    *bp, buf[128], name[64], display[64], args[128];
  172. X
  173. X    alrm.sv_handler = myalarm;
  174. X    alrm.sv_mask = 0;
  175. X    alrm.sv_flags = SV_INTERRUPT;
  176. X    sigvec (SIGALRM, &alrm, (struct sigvec *) 0);
  177. X
  178. X/*
  179. X *  Set real time clock to interrupt us every UPDATE_INTERVAL usecs.
  180. X */
  181. X
  182. X    update.it_interval.tv_sec = 0;
  183. X    update.it_interval.tv_usec = UPDATE_INTERVAL;
  184. X    update.it_value.tv_sec = 0;
  185. X    update.it_value.tv_usec = UPDATE_INTERVAL;
  186. X    setitimer (ITIMER_REAL, &update, 0);
  187. X
  188. X    pipe.sv_handler = SIG_DFL;
  189. X    pipe.sv_mask = 0;
  190. X    pipe.sv_flags = SV_INTERRUPT;
  191. X    sigvec (SIGPIPE, &pipe, (struct sigvec *) 0);
  192. X
  193. X    FD_ZERO (&ofdset);
  194. X    FD_ZERO (&fdset);
  195. X    FD_SET (listen_socket, &ofdset);
  196. X
  197. X    for (;;) {
  198. X
  199. X        sigsetmask (0);
  200. X
  201. X        fdset = ofdset;
  202. X        pno = select (32, &fdset, (fd_set *) NULL, (fd_set *) NULL,
  203. X            (struct itimerval *) NULL);
  204. X
  205. X        sigblock (SIGALRM);
  206. X
  207. X        if (pno < 0) {
  208. X            FD_CLR (listen_socket, &fdset);
  209. X            if (news > 0)
  210. X                FD_CLR (news, &fdset);
  211. X        }
  212. X
  213. X        if (FD_ISSET (listen_socket, &fdset) ||
  214. X            (news > 0 && FD_ISSET(news, &fdset))) {
  215. X            if (news == -1) {
  216. X                addrlen = sizeof (addr);
  217. X                news = accept(listen_socket, &addr, &addrlen);
  218. X                if (news > 0) {
  219. X                    peerdied = 0;
  220. X                    pipe.sv_handler = deadpeer;
  221. X                    sigvec(SIGPIPE, &pipe, (struct sigvec *) 0);
  222. X                    ioctl (news, FIONBIO, &on);
  223. X                    FD_SET (news, &ofdset);
  224. X                    bp = buf;
  225. X                }
  226. X            }
  227. X            if (news > 0) {
  228. X                if ((n = read (news, bp, 1)) > 0) {
  229. X                    if (*bp == '\n') {
  230. X                        *bp = '\0';
  231. X                        parseinfo (buf, display,
  232. X                            name, args);
  233. X                        if (newPlayer (news,
  234. X                            display, name, args) == 0)
  235. X                            write (news, "Ready.\n", 7);
  236. X                            printf ("%s\n", display);
  237. X                        close (news);
  238. X                        news = -1;
  239. X                    }
  240. X                    else
  241. X                        bp++;
  242. X                    playerchange = 1;
  243. X                }
  244. X                if (n == 0)
  245. X                    peerdied = 1;
  246. X            }
  247. X        }
  248. X
  249. X        if (playerchange) {
  250. X            FD_ZERO (&ofdset);
  251. X            FD_SET (listen_socket, &ofdset);
  252. X            if (news >= 0)
  253. X                FD_SET (news, &ofdset);
  254. X            pipe.sv_handler = SIG_DFL;
  255. X            sigvec (SIGPIPE, &pipe, (struct sigvec *) 0);
  256. X            playerchange = 0;
  257. X        }
  258. X
  259. X        if (doUpdate) {
  260. X            doUpdate = 0;
  261. X            redraw ();
  262. X        }
  263. X
  264. X    }
  265. X}
  266. *-*-END-of-./fsim/server.c-*-*
  267. echo x - ./fsim/scale.h
  268. sed 's/^X//' >./fsim/scale.h <<'*-*-END-of-./fsim/scale.h-*-*'
  269. Xtypedef struct {
  270. X    int    xorg;        /* x loc of bottom of scale */
  271. X    int    yorg;        /* y loc of bottom of scale */
  272. X    int    length;        /* length of scale (pixels) */
  273. X    int    orientation;    /* orientation flags */
  274. X    double    scale;        /* units per pixel */
  275. X    int    minorInterval;    /* units per minor tick */
  276. X    int    minorSize;    /* width of minor ticks (pixels) */
  277. X    int    majorInterval;    /* units per major tick */
  278. X    int    majorSize;    /* width of major ticks (pixels) */
  279. X    int    indexSize;    /* width of index (pixels) */
  280. X    double    divisor;    /* divisor on digit scale */
  281. X    char    *format;    /* output format */
  282. X    }    scaleControl;
  283. X
  284. X#define orientRight        1
  285. X#define orientHorizontal    2
  286. *-*-END-of-./fsim/scale.h-*-*
  287. echo x - ./fsim/eng.xbm
  288. sed 's/^X//' >./fsim/eng.xbm <<'*-*-END-of-./fsim/eng.xbm-*-*'
  289. X#define eng_width 64
  290. X#define eng_height 64
  291. X#define eng_x_hot 31
  292. X#define eng_y_hot 31
  293. Xstatic char eng_bits[] = {
  294. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
  295. X   0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x01, 0x00, 0x00,
  296. X   0x00, 0x00, 0xf8, 0x03, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x36, 0xc0,
  297. X   0x01, 0x36, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xc0, 0x01, 0x58, 0x00, 0x00,
  298. X   0x00, 0xc0, 0x03, 0x80, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x00, 0x80,
  299. X   0x00, 0x80, 0x03, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  300. X   0x00, 0x14, 0x00, 0xc0, 0x00, 0x00, 0x14, 0x00, 0x00, 0x0a, 0x00, 0x20,
  301. X   0x01, 0x00, 0x28, 0x00, 0x00, 0x05, 0x00, 0x20, 0x01, 0x00, 0x52, 0x00,
  302. X   0x00, 0x03, 0x00, 0x20, 0x01, 0x00, 0x64, 0x00, 0x80, 0x01, 0x00, 0x20,
  303. X   0x01, 0x00, 0xce, 0x00, 0xc0, 0x00, 0x00, 0x20, 0x01, 0x00, 0x83, 0x01,
  304. X   0xc0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x80, 0x01, 0x60, 0x00, 0x00, 0x00,
  305. X   0x00, 0x00, 0x00, 0x03, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
  306. X   0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x28, 0x00, 0x00, 0x00,
  307. X   0x00, 0x00, 0x00, 0x0a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c,
  308. X   0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x00,
  309. X   0x00, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
  310. X   0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x00,
  311. X   0x00, 0x00, 0x00, 0x18, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
  312. X   0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x06, 0x62, 0x0c, 0x00,
  313. X   0x00, 0x80, 0x31, 0x30, 0x06, 0x93, 0x12, 0x00, 0x00, 0x40, 0x48, 0x30,
  314. X   0x76, 0x92, 0x12, 0x00, 0x00, 0x40, 0x48, 0x37, 0x56, 0x92, 0x12, 0x80,
  315. X   0x00, 0x80, 0x49, 0x35, 0x76, 0x92, 0x12, 0x00, 0x00, 0x40, 0x4a, 0x37,
  316. X   0x06, 0x92, 0x12, 0x00, 0x00, 0x40, 0x4a, 0x30, 0x06, 0x67, 0x0c, 0x00,
  317. X   0x00, 0x80, 0x31, 0x30, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
  318. X   0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0xe7,
  319. X   0x44, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x29, 0x45, 0x00, 0x00, 0x18,
  320. X   0x0c, 0x00, 0x00, 0x29, 0x6d, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0xe7,
  321. X   0x54, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x23, 0x54, 0x00, 0x00, 0x0c,
  322. X   0x18, 0x00, 0x00, 0x2d, 0x44, 0x00, 0x00, 0x0c, 0x28, 0x00, 0x00, 0x29,
  323. X   0x44, 0x00, 0x00, 0x0a, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
  324. X   0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x60, 0x00, 0x00, 0x00,
  325. X   0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x01,
  326. X   0xc0, 0x40, 0x00, 0x30, 0x06, 0x00, 0x81, 0x01, 0x80, 0x69, 0x00, 0x48,
  327. X   0x09, 0x00, 0xcb, 0x00, 0x00, 0x33, 0x00, 0x48, 0x09, 0x00, 0x66, 0x00,
  328. X   0x00, 0x25, 0x00, 0x30, 0x09, 0x00, 0x52, 0x00, 0x00, 0x0a, 0x00, 0x48,
  329. X   0x09, 0x00, 0x28, 0x00, 0x00, 0x14, 0x00, 0x48, 0x09, 0x00, 0x14, 0x00,
  330. X   0x00, 0x38, 0x00, 0x30, 0x06, 0x00, 0x0e, 0x00, 0x00, 0xe0, 0x00, 0x80,
  331. X   0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x80, 0x00, 0xe0, 0x01, 0x00,
  332. X   0x00, 0x00, 0x0d, 0x40, 0x01, 0x58, 0x00, 0x00, 0x00, 0x00, 0x36, 0xc0,
  333. X   0x01, 0x36, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xe0, 0x0f, 0x00, 0x00,
  334. X   0x00, 0x00, 0xc0, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
  335. X   0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  336. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  337. *-*-END-of-./fsim/eng.xbm-*-*
  338. echo x - ./fsim/getStick.c
  339. sed 's/^X//' >./fsim/getStick.c <<'*-*-END-of-./fsim/getStick.c-*-*'
  340. X/*
  341. X *    xflight : an aerial combat simulator for X
  342. X *
  343. X *    Written by Riley Rainey,  riley@mips.com
  344. X *
  345. X *    Permission to use, copy, modify and distribute (without charge) this
  346. X *    software, documentation, images, etc. is granted, provided that this 
  347. X *    comment and the author's name is retained.
  348. X *
  349. X */
  350. X#include "pm.h"
  351. X#include <math.h>
  352. X
  353. X/*
  354. X *  getStick :  get stick input from mouse
  355. X *        inputs Sa and Se range from -1.0 to 1.0.
  356. X */
  357. X
  358. Xint getStick (c, u)
  359. Xcraft *c;
  360. Xviewer *u; {
  361. X
  362. X    int    rootX, rootY, x, y;
  363. X    Window    root, child;
  364. X    unsigned int mask;
  365. X    double    d, fuzz;
  366. X
  367. X    if (XQueryPointer (u->dpy, u->win, &root, &child, &rootX, &rootY,
  368. X        &x, &y, &mask) == True) {
  369. X
  370. X        if (x >= 0 && y >= 0 && x < u->width && y < u->height) {
  371. X
  372. X            fuzz = (double) u->width / 48.0;
  373. X            x = x - u->xCenter;
  374. X            y = y - u->yCenter;
  375. X            d = sqrt ((double)(x*x + y*y));
  376. X
  377. X            if (d > fuzz) {
  378. X                c->Sa=(double) x / (double) u->xCenter * (d-fuzz) / d;
  379. X                c->Se=(double) y / (double) u->yCenter * (d-fuzz) / d;
  380. X#ifndef LINEAR_CONTROL_RESPONSE
  381. X                if (c->Sa < 0.0)
  382. X                    c->Sa =  - c->Sa * c->Sa;
  383. X                else
  384. X                    c->Sa = c->Sa * c->Sa;
  385. X
  386. X                if (c->Se < 0.0)
  387. X                    c->Se = - c->Se * c->Se;
  388. X                else
  389. X                    c->Se = c->Se * c->Se;
  390. X#endif
  391. X            }
  392. X            else {
  393. X                c->Sa = 0.0;
  394. X                c->Se = 0.0;
  395. X            }
  396. X            return 1;
  397. X
  398. X        }
  399. X    }
  400. X
  401. X    return 0;
  402. X}
  403. *-*-END-of-./fsim/getStick.c-*-*
  404. echo x - ./fsim/header
  405. sed 's/^X//' >./fsim/header <<'*-*-END-of-./fsim/header-*-*'
  406. X/*
  407. X *    xflight : an aerial combat simulator for X
  408. X *
  409. X *    Written by Riley Rainey,  riley@mips.com
  410. X *
  411. X *    Permission to use, copy, modify and distribute (without charge) this
  412. X *    software, documentation, images, etc. is granted, provided that this 
  413. X *    comment and the author's name is retained.
  414. X *
  415. *-*-END-of-./fsim/header-*-*
  416. echo x - ./fsim/rwy2
  417. sed 's/^X//' >./fsim/rwy2 <<'*-*-END-of-./fsim/rwy2-*-*'
  418. XRunway
  419. X4 1
  420. X1 0 -75.000000 0
  421. X2 12000 -75 0
  422. X3 12000 75.000000 0
  423. X4 0 75.000000 0
  424. X#b7b19f 4  1 2 3 4
  425. *-*-END-of-./fsim/rwy2-*-*
  426. echo x - ./fsim/droneCalculations.c
  427. sed 's/^X//' >./fsim/droneCalculations.c <<'*-*-END-of-./fsim/droneCalculations.c-*-*'
  428. X/*
  429. X *    xflight : an aerial combat simulator for X
  430. X *
  431. X *    Written by Riley Rainey,  riley@mips.com
  432. X *
  433. X *    Permission to use, copy, modify and distribute (without charge) this
  434. X *    software, documentation, images, etc. is granted, provided that this 
  435. X *    comment and the author's name is retained.
  436. X *
  437. X */
  438. X
  439. X#include "pm.h"
  440. X
  441. X/*
  442. X *  Drone flight management
  443. X */
  444. X
  445. Xint droneCalculations (c)
  446. Xcraft *c; {
  447. X
  448. X    c->prevSg = c->Sg;
  449. X
  450. X    c->Sg.x += c->Cg.x * deltaT;
  451. X    c->Sg.y += c->Cg.y * deltaT;
  452. X    c->Sg.z += c->Cg.z * deltaT;
  453. X
  454. X/*
  455. X *  Don't let drones get above 60 thousand feet
  456. X */
  457. X
  458. X    if (c->Sg.z < -60000.0)
  459. X        return 1;
  460. X
  461. X/*
  462. X *  Drone crash detection
  463. X */
  464. X
  465. X    if (c->Sg.z > 0.0)
  466. X        return 1;
  467. X
  468. X    return 0;
  469. X}
  470. *-*-END-of-./fsim/droneCalculations.c-*-*
  471. echo x - ./fsim/flaps1.xbm
  472. sed 's/^X//' >./fsim/flaps1.xbm <<'*-*-END-of-./fsim/flaps1.xbm-*-*'
  473. X#define flaps1_width 64
  474. X#define flaps1_height 32
  475. X#define flaps1_x_hot -1
  476. X#define flaps1_y_hot -1
  477. Xstatic char flaps1_bits[] = {
  478. X   0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0xde, 0xdd, 0xfd,
  479. X   0x1f, 0x00, 0x00, 0x00, 0x60, 0xef, 0xee, 0xee, 0xee, 0xff, 0x03, 0x00,
  480. X   0x70, 0x77, 0x77, 0x77, 0x77, 0xf7, 0x3f, 0x00, 0x58, 0xbb, 0xbb, 0xbb,
  481. X   0xbb, 0x7b, 0x01, 0x00, 0x48, 0xdf, 0xdd, 0xdd, 0xdd, 0x3d, 0x0f, 0x00,
  482. X   0xe8, 0xfe, 0xff, 0xff, 0xff, 0x9f, 0x3f, 0x00, 0x38, 0x00, 0x00, 0x00,
  483. X   0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07,
  484. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00,
  485. X   0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  486. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  487. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  488. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  489. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  490. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  491. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  492. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  493. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  494. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  495. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  496. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  497. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  498. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  499. X   0x00, 0x00, 0x00, 0x00};
  500. *-*-END-of-./fsim/flaps1.xbm-*-*
  501. echo x - ./fsim/aim-9
  502. sed 's/^X//' >./fsim/aim-9 <<'*-*-END-of-./fsim/aim-9-*-*'
  503. X#
  504. X63 4
  505. X1 -0.9167 0 0
  506. X2 -0.9167 0.0833 0
  507. X3 -1 0.1667 0
  508. X4 -1.6667 0.25 0
  509. X5 -1.8333 0.25 0
  510. X6 -2.3333 0.8333 0
  511. X7 -2.4167 1 0
  512. X8 -2.4167 0.25 0
  513. X9 -7.5833 0.25 0
  514. X10 -8 1 0
  515. X11 -9 1 0
  516. X12 -9 -1 0
  517. X13 -8 -1 0
  518. X14 -7.5833 -0.25 0
  519. X15 -2.4167 -0.25 0
  520. X16 -2.4167 -1 0
  521. X17 -2.3333 -0.8333 0
  522. X18 -1.8333 -0.25 0
  523. X19 -1.6667 -0.25 0
  524. X20 -1 -0.1667 0
  525. X21 -0.9167 -0.0833 0
  526. X1 -0.9167 0 0
  527. X2 -0.9167 0 0.0833
  528. X3 -1 0 0.1667
  529. X4 -1.6667 0 0.25
  530. X5 -1.8333 0 0.25
  531. X6 -2.3333 0 0.8333
  532. X7 -2.4167 0 1
  533. X8 -2.4167 0 0.25
  534. X9 -7.5833 0 0.25
  535. X10 -8 0 1
  536. X11 -9 0 1
  537. X12 -9 0 -1
  538. X13 -8 0 -1
  539. X14 -7.5833 0 -0.25
  540. X15 -2.4167 0 -0.25
  541. X16 -2.4167 0 -1
  542. X17 -2.3333 0 -0.8333
  543. X18 -1.8333 0 -0.25
  544. X19 -1.6667 0 -0.25
  545. X20 -1 0 -0.1667
  546. X21 -0.9167 0 -0.0833
  547. X43 -9 0.25 0
  548. X44 -9 0.1768 0.1768
  549. X45 -9 0 0.25
  550. X46 -9 -0.1768 0.1768
  551. X47 -9 -0.25 0
  552. X48 -9 -0.1768 -0.1768
  553. X49 -9 0 -0.25
  554. X50 -9 0.1768 -0.1768
  555. X51 -9 -0.25 0
  556. X52 -9.75 -0.5 0
  557. X53 -12 -0.75 0
  558. X54 -13.5 -0.75 0
  559. X55 -12.75 -0.5 0
  560. X56 -15.25 -0.5 0
  561. X57 -19.9167 0 0
  562. X58 -15.0833 0.4167 0
  563. X59 -15.75 0.5 0
  564. X60 -12.5833 0.6667 0
  565. X61 -12.0833 0.5833 0
  566. X62 -9.833 0.5 0
  567. X63 -9 0.25 0
  568. Xwhite 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
  569. Xwhite 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  570. Xwhite 8 43 44 45 46 47 48 49 50
  571. Xwhite 13 51 52 53 54 55 56 57 58 59 60 61 62 63
  572. *-*-END-of-./fsim/aim-9-*-*
  573. echo x - ./fsim/missileCalculations.c
  574. sed 's/^X//' >./fsim/missileCalculations.c <<'*-*-END-of-./fsim/missileCalculations.c-*-*'
  575. X/*
  576. X *    xflight : an aerial combat simulator for X
  577. X *
  578. X *    Written by Riley Rainey,  riley@mips.com
  579. X *
  580. X *    Permission to use, copy, modify and distribute (without charge) this
  581. X *    software, documentation, images, etc. is granted, provided that this 
  582. X *    comment and the author's name is retained.
  583. X *
  584. X */
  585. X#include <stdio.h>
  586. X#include <math.h>
  587. X#include "pm.h"
  588. X
  589. Xint mdebug = 0;
  590. Xextern double calcRho();
  591. X
  592. Xint  missileCalculations (c)
  593. Xcraft *c; {
  594. X
  595. X    double    q, rho, CLift, CDrag;
  596. X    double    FLift, FDrag, FWeight;
  597. X    double    Vmag, angle;
  598. X    double  deltaRoll, deltaPitch, deltaYaw;
  599. X    VPoint    F, Fg, tmpPt, r;
  600. X    VMatrix turn, tmpMatrix, mtx;
  601. X
  602. X/*
  603. X *  Check for ground impact.  We do this at the beginning to permit us to
  604. X *  kill ground targets.
  605. X */
  606. X
  607. X    if (c->Sg.z > 0.0) {
  608. X        killMissile (c);
  609. X        return 1;
  610. X    }
  611. X
  612. X    trackTarget (c);
  613. X
  614. X    -- c->armFuse;
  615. X
  616. X/*
  617. X *  Re-orient the body of the missile towards it's intended target.
  618. X */
  619. X
  620. X    c->prevSg = c->Sg;
  621. X
  622. X    rho = calcRho (-(c->Sg.z));
  623. X
  624. X/*
  625. X *  Compute the resultant force vector on the missile.
  626. X */
  627. X
  628. X    Vmag = mag(c->Cg);
  629. X    q = rho * c->cinfo->wingS * Vmag * Vmag * 0.5;
  630. X    FLift = 0.0;
  631. X    FDrag = c->cinfo->CDOrigin * q;
  632. X
  633. X    if (mdebug) {
  634. X    printf ("rho = %g, FLift = %g, FDrag = %g\n", rho, FLift, FDrag);
  635. X    printf ("FThrust = %g\n", c->curThrust);
  636. X    }
  637. X
  638. X    F.x = c->curThrust - FDrag;
  639. X    F.y = 0.0; 
  640. X    F.z = 0.0; 
  641. X
  642. X/*
  643. X *  Now calculate changes in position (Sg) and velocity (Cg).
  644. X */
  645. X
  646. X    if ((c->fuel -= fuelUsed(c)) <= 0.0) {
  647. X        if (c->curThrust > 0.0)
  648. X            if (mdebug)
  649. X            printf ("Missile burnout; velocity = %g fps (%g kts)\n", Vmag,
  650. X                FPStoKTS(Vmag));
  651. X        c->fuel = 0.0;
  652. X        c->curThrust = 0.0;
  653. X    }
  654. X
  655. X/*
  656. X *  Normalize picth and heading Euler angles
  657. X */
  658. X
  659. X    if (c->curPitch > pi / 2.0) {
  660. X        c->curPitch = pi - c->curPitch;    
  661. X        c->curHeading = (c->curHeading > pi) ?
  662. X            c->curHeading - pi : c->curHeading + pi;
  663. X        c->curRoll = pi - c->curRoll;
  664. X    }
  665. X    else if (c->curPitch < -pi/2.0) {
  666. X        c->curPitch = -pi - c->curPitch;
  667. X        c->curHeading = (c->curHeading > pi) ?
  668. X            c->curHeading - pi : c->curHeading + pi;
  669. X        c->curRoll = pi - c->curRoll;
  670. X        }
  671. X
  672. X    if (c->curHeading < 0.0) {
  673. X        c->curHeading += 2.0 * pi;
  674. X    }
  675. X    else if (c->curHeading > 2.0 * pi) {
  676. X        c->curHeading -= 2.0 * pi;
  677. X    }
  678. X
  679. X/*
  680. X *  Compute transformation matricies
  681. X */
  682. X
  683. X        VIdentMatrix (&mtx);
  684. X        if (c->curRoll != 0.0)
  685. X                VRotate (&mtx, XRotation, c->curRoll);
  686. X    if (c->curPitch != 0.0)
  687. X                VRotate (&mtx, YRotation, -c->curPitch);
  688. X        if (c->curHeading != 0.0)
  689. X                VRotate (&mtx, ZRotation, c->curHeading);
  690. X    c->trihedral = mtx;
  691. X
  692. X    transpose (&c->trihedral, &c->Itrihedral);
  693. X
  694. X    craftToGround (c, &F, &Fg);
  695. X    FWeight = c->cinfo->emptyWeight + c->fuel;
  696. X    Fg.z += FWeight;
  697. X
  698. X    if (mdebug) {
  699. X            printf ("v = %g, Fg = { %g, %g, %g }\n", FPStoKTS(Vmag),
  700. X            Fg.x, Fg.y, Fg.z);
  701. X            printf ("F = { %g, %g, %g }\n", F.x, F.y, F.z);
  702. X    }
  703. X
  704. X
  705. X
  706. X/*
  707. X *  Update the missile's position and velocity.
  708. X */
  709. X
  710. X
  711. X    c->Sg.x += c->Cg.x * deltaT + Fg.x / FWeight * a * halfDeltaTSquared;
  712. X    c->Sg.y += c->Cg.y * deltaT + Fg.y / FWeight * a * halfDeltaTSquared;
  713. X    c->Sg.z += c->Cg.z * deltaT + Fg.z / FWeight * a * halfDeltaTSquared;
  714. X
  715. X    c->Cg.x += Fg.x / FWeight * a * deltaT;
  716. X    c->Cg.y += Fg.y / FWeight * a * deltaT;
  717. X    c->Cg.z += Fg.z / FWeight * a * deltaT;
  718. X
  719. X
  720. X    if (mdebug) {
  721. X        printf ("Altitude = %g\n", -c->Sg.z);
  722. X        printf ("Euler angles { %g, %g, %g }\n", RADtoDEG(c->curRoll),
  723. X            RADtoDEG(c->curPitch), RADtoDEG(c->curHeading));
  724. X        printf ("Cg = { %g, %g, %g }\n", c->Cg.x, c->Cg.y, c->Cg.z);
  725. X        printf ("Sg = { %g, %g, %g }\n", c->Sg.x, c->Sg.y, c->Sg.z);
  726. X    }
  727. X
  728. X    return 0;
  729. X}
  730. *-*-END-of-./fsim/missileCalculations.c-*-*
  731. echo x - ./fsim/flaps2.xbm
  732. sed 's/^X//' >./fsim/flaps2.xbm <<'*-*-END-of-./fsim/flaps2.xbm-*-*'
  733. X#define flaps2_width 64
  734. X#define flaps2_height 32
  735. X#define flaps2_x_hot -1
  736. X#define flaps2_y_hot -1
  737. Xstatic char flaps2_bits[] = {
  738. X   0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xdd, 0xfd,
  739. X   0x1f, 0x00, 0x00, 0x00, 0x20, 0xef, 0xee, 0xee, 0xee, 0xff, 0x03, 0x00,
  740. X   0x30, 0x77, 0x77, 0x77, 0x77, 0xf7, 0x3f, 0x00, 0x38, 0xbb, 0xbb, 0xbb,
  741. X   0xbb, 0x7b, 0x00, 0x00, 0x28, 0xdf, 0xdd, 0xdd, 0xdd, 0x3d, 0x0e, 0x00,
  742. X   0x6c, 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x1e, 0x00, 0x3c, 0x00, 0x00, 0x00,
  743. X   0x00, 0x00, 0x3c, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00,
  744. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00,
  745. X   0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
  746. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
  747. X   0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  748. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  749. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  750. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  751. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  752. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  753. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  754. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  755. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  756. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  757. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  758. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  759. X   0x00, 0x00, 0x00, 0x00};
  760. *-*-END-of-./fsim/flaps2.xbm-*-*
  761. echo x - ./fsim/flaps.c
  762. sed 's/^X//' >./fsim/flaps.c <<'*-*-END-of-./fsim/flaps.c-*-*'
  763. X/*
  764. X *    xflight : an aerial combat simulator for X
  765. X *
  766. X *    Written by Riley Rainey,  riley@mips.com
  767. X *
  768. X *    Permission to use, copy, modify and distribute (without charge) this
  769. X *    software, documentation, images, etc. is granted, provided that this 
  770. X *    comment and the author's name is retained.
  771. X *
  772. X */
  773. X#include "pm.h"
  774. X
  775. Xint    flapsDown (c)
  776. Xcraft    *c; {
  777. X
  778. X    c->flapSetting += 10.0 * pi / 180.0;
  779. X    if (c->flapSetting > c->cinfo->maxFlap)
  780. X        c->flapSetting = c->cinfo->maxFlap;
  781. X    return 0;
  782. X}
  783. X
  784. Xint    flapsUp (c)
  785. Xcraft    *c; {
  786. X
  787. X    c->flapSetting -= 10.0 * pi / 180.0;
  788. X    if (c->flapSetting < 0.0)
  789. X        c->flapSetting = 0.0;
  790. X    return 0;
  791. X}
  792. X
  793. Xvoid    flapControl (c)
  794. Xcraft    *c; {
  795. X
  796. X    if (c->flapSetting > c->curFlap) {
  797. X        c->curFlap += c->cinfo->flapRate * deltaT;
  798. X        if (c->curFlap > c->flapSetting)
  799. X            c->curFlap = c->flapSetting;
  800. X    }
  801. X    else if (c->flapSetting < c->curFlap) {
  802. X        c->curFlap -= c->cinfo->flapRate * deltaT;
  803. X        if (c->curFlap < c->flapSetting)
  804. X            c->curFlap = c->flapSetting;
  805. X    }
  806. X
  807. X    if (c->speedBrakeSetting > c->curSpeedBrake) {
  808. X        c->curSpeedBrake += c->cinfo->speedBrakeRate * deltaT;
  809. X        if (c->curSpeedBrake > c->speedBrakeSetting)
  810. X            c->curSpeedBrake = c->speedBrakeSetting;
  811. X    }
  812. X    else if (c->speedBrakeSetting < c->curSpeedBrake) {
  813. X        c->curSpeedBrake -= c->cinfo->speedBrakeRate * deltaT;
  814. X        if (c->curSpeedBrake < c->speedBrakeSetting)
  815. X            c->curSpeedBrake = c->speedBrakeSetting;
  816. X    }
  817. X}
  818. X
  819. Xint    speedBrakeExtend (c)
  820. Xcraft    *c; {
  821. X
  822. X    c->speedBrakeSetting += c->cinfo->speedBrakeIncr;
  823. X    if (c->speedBrakeSetting > c->cinfo->maxSpeedBrake)
  824. X        c->speedBrakeSetting = c->cinfo->maxSpeedBrake;
  825. X    return 0;
  826. X}
  827. X
  828. Xint    speedBrakeRetract (c)
  829. Xcraft    *c; {
  830. X
  831. X    c->speedBrakeSetting -= c->cinfo->speedBrakeIncr;
  832. X    if (c->speedBrakeSetting < 0.0)
  833. X        c->speedBrakeSetting = 0.0;
  834. X    return 0;
  835. X}
  836. *-*-END-of-./fsim/flaps.c-*-*
  837. echo x - ./fsim/exp1.xbm
  838. sed 's/^X//' >./fsim/exp1.xbm <<'*-*-END-of-./fsim/exp1.xbm-*-*'
  839. X#define exp1_width 64
  840. X#define exp1_height 64
  841. X#define exp1_x_hot -1
  842. X#define exp1_y_hot -1
  843. Xstatic char exp1_bits[] = {
  844. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
  845. X   0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x81, 0x00, 0x00, 0x00,
  846. X   0x00, 0x00, 0x00, 0x20, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
  847. X   0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x80, 0x61, 0x00, 0x03,
  848. X   0x00, 0x00, 0x00, 0x20, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40,
  849. X   0x80, 0x20, 0x80, 0x01, 0x00, 0x80, 0x40, 0x40, 0x80, 0x38, 0x80, 0x01,
  850. X   0x00, 0x80, 0x01, 0xa0, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00,
  851. X   0x82, 0x22, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0xc4, 0x00, 0x00, 0x00,
  852. X   0x00, 0x00, 0x00, 0x00, 0x06, 0x02, 0x10, 0x00, 0x80, 0x00, 0x0c, 0x80,
  853. X   0xa9, 0x00, 0x00, 0x00, 0x00, 0x01, 0xa8, 0x10, 0x93, 0x75, 0x02, 0x20,
  854. X   0x00, 0x00, 0xe0, 0x04, 0x3e, 0x03, 0x01, 0x20, 0x00, 0x04, 0x10, 0x92,
  855. X   0x8a, 0x0e, 0x06, 0x1a, 0x00, 0x5c, 0x81, 0xf1, 0xef, 0x1b, 0x80, 0x01,
  856. X   0x00, 0x18, 0x80, 0x0c, 0xcb, 0x01, 0xa5, 0x00, 0x00, 0x60, 0x88, 0x17,
  857. X   0x43, 0x07, 0x87, 0x00, 0x00, 0xa0, 0x21, 0x79, 0xc7, 0x51, 0x23, 0x00,
  858. X   0x00, 0x80, 0x40, 0x3f, 0xeb, 0x1e, 0x07, 0x00, 0x00, 0x00, 0x40, 0x1f,
  859. X   0xef, 0xb8, 0x17, 0x00, 0x00, 0x04, 0x04, 0x06, 0x2c, 0x71, 0x06, 0x00,
  860. X   0x00, 0x08, 0x00, 0x6b, 0x5f, 0x10, 0x02, 0x00, 0x00, 0x40, 0xf9, 0x38,
  861. X   0x01, 0xbf, 0x01, 0x00, 0x00, 0x00, 0xac, 0xb3, 0x5f, 0xfd, 0x03, 0x00,
  862. X   0x00, 0x00, 0xfc, 0xb9, 0x4f, 0xa7, 0x03, 0x10, 0x00, 0x00, 0xd7, 0xac,
  863. X   0xc2, 0x9a, 0x0d, 0x04, 0x10, 0x40, 0x7b, 0xc9, 0x98, 0x79, 0x11, 0x18,
  864. X   0x00, 0xc0, 0xfa, 0x8d, 0x18, 0xcb, 0x29, 0x02, 0x00, 0x80, 0xd8, 0x0d,
  865. X   0x88, 0x0b, 0x57, 0x08, 0x00, 0xc0, 0x0c, 0x39, 0x60, 0x1b, 0x00, 0x00,
  866. X   0x00, 0xd0, 0x64, 0x97, 0xc1, 0x73, 0x18, 0x03, 0x00, 0x6b, 0x81, 0x0e,
  867. X   0x01, 0xfb, 0x0c, 0x02, 0x00, 0x80, 0xdf, 0x15, 0x81, 0x54, 0xe8, 0x02,
  868. X   0x00, 0x00, 0xde, 0xff, 0xa2, 0xd9, 0x3c, 0x00, 0x00, 0x80, 0x3f, 0xde,
  869. X   0xc2, 0xac, 0x94, 0x00, 0x00, 0x00, 0x33, 0xde, 0xec, 0x0b, 0x1e, 0x02,
  870. X   0x00, 0xc0, 0x6c, 0x17, 0xe1, 0xe7, 0x1c, 0x02, 0x00, 0x50, 0x76, 0xfc,
  871. X   0xf7, 0xfe, 0x3f, 0x00, 0x00, 0x1c, 0x5d, 0x9c, 0xfa, 0xba, 0x09, 0x00,
  872. X   0x00, 0x04, 0x63, 0xcc, 0x0e, 0x8c, 0x89, 0x00, 0x00, 0x46, 0x82, 0x90,
  873. X   0x80, 0xbb, 0x12, 0x00, 0x00, 0x02, 0xe3, 0xd7, 0x89, 0x81, 0x23, 0x00,
  874. X   0x80, 0x81, 0x21, 0x83, 0x84, 0x89, 0x03, 0x00, 0x00, 0x00, 0x04, 0xf7,
  875. X   0xcc, 0xdb, 0xe3, 0x00, 0x20, 0xa0, 0x00, 0xa6, 0x7e, 0x0b, 0xb1, 0x01,
  876. X   0x20, 0x00, 0x00, 0x19, 0x6f, 0x4e, 0x8e, 0x00, 0x10, 0x00, 0x00, 0x1c,
  877. X   0xe0, 0x53, 0x06, 0x02, 0x00, 0x00, 0x00, 0x04, 0xe7, 0xa9, 0x00, 0x02,
  878. X   0x00, 0x00, 0x80, 0x43, 0x14, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
  879. X   0x00, 0x88, 0x00, 0x0c, 0x00, 0x00, 0xc0, 0x00, 0x0c, 0x40, 0x00, 0x08,
  880. X   0x00, 0x00, 0x40, 0x05, 0x08, 0x20, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00,
  881. X   0x04, 0x00, 0x02, 0x18, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x03, 0x10,
  882. X   0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x08, 0x08, 0x00,
  883. X   0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80, 0x00,
  884. X   0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
  885. X   0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x10, 0x00,
  886. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00};
  887. *-*-END-of-./fsim/exp1.xbm-*-*
  888. echo x - ./fsim/tower
  889. sed 's/^X//' >./fsim/tower <<'*-*-END-of-./fsim/tower-*-*'
  890. X*-a-control-tower
  891. X60 16
  892. X1 20 20 0
  893. X2 20 -20 0
  894. X3 12 -12 -60
  895. X4 12 12 -60
  896. X5 12 12 -60
  897. X6 12 -12 -60
  898. X7 12 -12 -64
  899. X8 12 12 -64
  900. X9 12 0.25 -64
  901. X10 12 -0.25 -64
  902. X11 12 -0.25 -72
  903. X12 12 0.25 -72
  904. X13 14 14 -72
  905. X14 14 -14 -72
  906. X15 0 0 -76
  907. X16 -20 -20 0
  908. X17 -20 20 0
  909. X18 -12 12 -60
  910. X19 -12 -12 -60
  911. X20 -12 -12 -60
  912. X21 -12 12 -60
  913. X22 -12 12 -64
  914. X23 -12 -12 -64
  915. X24 -12 -0.25 -64
  916. X25 -12 0.25 -64
  917. X26 -12 0.25 -72
  918. X27 -12 -0.25 -72
  919. X28 -14 -14 -72
  920. X29 -14 14 -72
  921. X30 0 0 -76
  922. X31 20 20 0
  923. X32 -20 20 0
  924. X33 -12 12 -60
  925. X34 12 12 -60
  926. X35 12 12 -60
  927. X36 -12 12 -60
  928. X37 -12 12 -64
  929. X38 12 12 -64
  930. X39 12 0.25 -64
  931. X40 -12 0.25 -64
  932. X41 -12 0.25 -72
  933. X42 12 0.25 -72
  934. X43 14 14 -72
  935. X44 -14 14 -72
  936. X45 0 0 -76
  937. X46 -20 -20 0
  938. X47 20 -20 0
  939. X48 12 -12 -60
  940. X49 -12 -12 -60
  941. X50 -12 -12 -60
  942. X51 12 -12 -60
  943. X52 12 -12 -64
  944. X53 -12 -12 -64
  945. X54 -12 -0.25 -64
  946. X55 12 -0.25 -64
  947. X56 12 -0.25 -72
  948. X57 -12 -0.25 -72
  949. X58 -14 -14 -72
  950. X59 14 -14 -72
  951. X60 0 0 -76
  952. Xgray33 4 1 2 3 4
  953. Xgray33 4 5 6 7 8
  954. Xgray33 4 9 10 11 12
  955. Xgray33 3 13 14 15
  956. Xgray33 4 16 17 18 19
  957. Xgray33 4 20 21 22 23
  958. Xgray33 4 24 25 26 27
  959. Xgray33 3 28 29 30
  960. Xgray33 4 31 32 33 34
  961. Xgray33 4 35 36 37 38
  962. Xgray33 4 39 40 41 42
  963. Xgray33 3 43 44 45
  964. Xgray33 4 46 47 48 49
  965. Xgray33 4 50 51 52 53
  966. Xgray33 4 54 55 56 57
  967. Xgray33 3 58 59 60
  968. *-*-END-of-./fsim/tower-*-*
  969. echo x - ./fsim/weapon.c
  970. sed 's/^X//' >./fsim/weapon.c <<'*-*-END-of-./fsim/weapon.c-*-*'
  971. X#include "pm.h"
  972. X
  973. Xint selectWeapon(c)
  974. Xcraft *c; {
  975. X
  976. X    register int n, m;
  977. X
  978. X    m = c->curWeapon;
  979. X    n = (c->curWeapon + 1) % WEAPONTYPES;
  980. X    for (; n != m; n = (n + 1) % WEAPONTYPES) {
  981. X        if (wtbl[n].select != NULL)
  982. X            if ((*wtbl[n].select)(c) == 1) {
  983. X                c->curWeapon = n;
  984. X                return 1;
  985. X            }
  986. X    }
  987. X
  988. X    return 0;
  989. X}
  990. X
  991. Xint fireWeapon (c)
  992. Xcraft *c; {
  993. X
  994. X    if (wtbl[c->curWeapon].firePress != NULL)
  995. X        return (*wtbl[c->curWeapon].firePress)(c);
  996. X
  997. X    return 0;
  998. X}
  999. X
  1000. Xint ceaseFireWeapon (c)
  1001. Xcraft *c; {
  1002. X
  1003. X    if (wtbl[c->curWeapon].fireRelease != NULL)
  1004. X        return (*wtbl[c->curWeapon].fireRelease)(c);
  1005. X
  1006. X    return 0;
  1007. X}
  1008. X
  1009. Xint doWeaponDisplay (c, u)
  1010. Xcraft *c;
  1011. Xviewer *u; {
  1012. X
  1013. X    int    i;
  1014. X
  1015. X    if (wtbl[c->curWeapon].display != NULL)
  1016. X        return (*wtbl[c->curWeapon].display)(c, wtbl[c->curWeapon].w, u);
  1017. X    else {
  1018. X        for (i=0; i<3; i++)
  1019. X            strcpy (c->leftHUD[i], "");
  1020. X    }
  1021. X
  1022. X    return 0;
  1023. X}
  1024. X
  1025. Xint doWeaponUpdate (c)
  1026. Xcraft *c; {
  1027. X
  1028. X    if (wtbl[c->curWeapon].update != NULL)
  1029. X        return (*wtbl[c->curWeapon].update)(c);
  1030. X
  1031. X    return 0;
  1032. X}
  1033. *-*-END-of-./fsim/weapon.c-*-*
  1034. echo x - ./fsim/aim9m.c
  1035. sed 's/^X//' >./fsim/aim9m.c <<'*-*-END-of-./fsim/aim9m.c-*-*'
  1036. X/*
  1037. X *    xflight : an aerial combat simulator for X
  1038. X *
  1039. X *    Written by Riley Rainey,  riley@mips.com
  1040. X *
  1041. X *    Permission to use, copy, modify and distribute (without charge) this
  1042. X *    software, documentation, images, etc. is granted, provided that this 
  1043. X *    comment and the author's name is retained.
  1044. X *
  1045. X */
  1046. X#include "pm.h"
  1047. X#include <stdio.h>
  1048. X#include <string.h>
  1049. X#include <math.h>
  1050. X
  1051. Xint select_aim9m();
  1052. Xint display_aim9m();
  1053. Xint getIRTarget();
  1054. Xextern int fireMissile ();
  1055. Xextern void createMissileEyeSpace();
  1056. X
  1057. XweaponDesc aim9mDesc = {
  1058. X    WK_AIM9M,
  1059. X    select_aim9m,        /* select */
  1060. X    (int (*)()) NULL,    /* update */
  1061. X    display_aim9m,        /* display procedure */
  1062. X    fireMissile,        /* fire */
  1063. X    (int (*)()) NULL,    /* fire button release */
  1064. X    };
  1065. X
  1066. X/*
  1067. X *  aim9m selection function
  1068. X *
  1069. X *  A selection function normally determines whether there are any weapons
  1070. X *  of this type on-board.  If so, and the weapon system is functional
  1071. X *  (in other words, undamaged) then return 1; otherwise return 0.
  1072. X */
  1073. X
  1074. Xint select_aim9m (c)
  1075. Xcraft *c; {
  1076. X
  1077. X    return 1;
  1078. X
  1079. X}
  1080. X
  1081. X/*
  1082. X * aim9m display function
  1083. X *
  1084. X *  Update the HUD display strings associated with this weapon system.
  1085. X */
  1086. X
  1087. Xint display_aim9m (c, w, u)
  1088. Xcraft *c;
  1089. XcraftType *w;
  1090. Xviewer *u; {
  1091. X
  1092. X    char    s[16];
  1093. X    double    d, a1, v, r, root1, root2, n, t;
  1094. X    VPoint    tmp;
  1095. X    VMatrix    m;
  1096. X    int    target, count;
  1097. X
  1098. X    count = 8;
  1099. X
  1100. X    sprintf (s, "%d AIM-9M", count);
  1101. X    strcpy (c->leftHUD[1], s);
  1102. X
  1103. X    a1 = w->maxThrust / (w->emptyWeight + w->maxFuel) * a;
  1104. X    v = mag (c->Cg);
  1105. X    a1 -= c->rho * c->cinfo->CDOrigin * v * v;
  1106. X
  1107. X    if (c->curRadarTarget >= 0 && a1 != 0.0) {
  1108. X
  1109. X    d = c->targetDistance;
  1110. X    r = c->targetClosure;
  1111. X
  1112. X    n = 4.0 * d / a1 + (r * r) / (a1 * a1);
  1113. X    if (n > 0) {
  1114. X        n = sqrt (n);
  1115. X        root1 = (- r / a + n) / 2.0;
  1116. X        root2 = (- r / a - n) / 2.0;
  1117. X        if (root1 >= 0.0)
  1118. X            if (root2 >= 0.0)
  1119. X                if (root1 < root2)
  1120. X                    t = root1;
  1121. X                else
  1122. X                    t = root2;
  1123. X            else
  1124. X                t = root1;
  1125. X        else if (root2 >= 0.0)
  1126. X            t = root2;
  1127. X        else
  1128. X            t = -1.0;
  1129. X    }
  1130. X    else
  1131. X        t = -1.0;
  1132. X    }
  1133. X
  1134. X    else
  1135. X        t = -1.0;
  1136. X
  1137. X/*
  1138. X *  See if the missiles can lock onto any target.
  1139. X */
  1140. X
  1141. X    if (count > 0) {
  1142. X        createMissileEyeSpace (c, &m);
  1143. X        target = getIRTarget (c, &m, &tmp);
  1144. X    }
  1145. X    else
  1146. X        target = -1;
  1147. X
  1148. X    if (target >= 0 && t <= 15.0)
  1149. X        sprintf (s, "LOCKED   %d", (int)(t+0.5));
  1150. X    else if (t < 0.0)
  1151. X        sprintf (s, "ARM      --");
  1152. X    else if (t <= 15.0)
  1153. X        sprintf (s, "IN RANGE %d", (int)(t+0.5));
  1154. X    else 
  1155. X        sprintf (s, "ARM      %d", (int)(t+0.5));
  1156. X
  1157. X    strcpy (c->leftHUD[0], s);
  1158. X
  1159. X    strcpy (c->leftHUD[2], "");
  1160. X
  1161. X}
  1162. X
  1163. Xextern craftType * newCraft ();
  1164. Xextern char * strdup();
  1165. X
  1166. Xvoid initaim9()
  1167. X{
  1168. X
  1169. X    craftType    *c;
  1170. X    FILE        *f;
  1171. X
  1172. X    c = newCraft();
  1173. X    c->name = strdup("aim-9m");
  1174. X
  1175. X    wtbl[0] = aim9mDesc;
  1176. X    wtbl[0].w = c;
  1177. X
  1178. X    c->CLOrigin = 0.0;
  1179. X    c->CLSlope = 4.41235;
  1180. X    c->CLNegStall = -15.0 * pi / 180.0;
  1181. X    c->CLPosStall =  15.0 * pi / 180.0;
  1182. X
  1183. X    c->CDOrigin = 0.1963494;    /* 4" radius of body */
  1184. X    c->CDFactor = -2.56694;
  1185. X    c->CDPhase = 0.0;
  1186. X
  1187. X    c->CDBOrigin = 0.0;
  1188. X    c->CDBFactor = 0.0;
  1189. X    c->CDBPhase = 0.0;
  1190. X
  1191. X    c->CMOrigin = 0.0;
  1192. X    c->CMFactor = -0.75;
  1193. X
  1194. X    c->CNOrigin = 0.0;
  1195. X    c->CNFactor = -0.75;
  1196. X
  1197. X    VIdentMatrix(&(c->I));
  1198. X    c->I.m[0][0] =  0.0;
  1199. X    c->I.m[1][1] = 0.0;
  1200. X    c->I.m[2][2] = 0.0;
  1201. X    c->LDamp =  700000.0;
  1202. X    c->MDamp = 1000000.0;
  1203. X    c->NDamp = 1000000.0;
  1204. X    c->cmSlope = -1.88;
  1205. X    c->cmFactor = -1.00;
  1206. X    c->cnSlope = 1.00;
  1207. X    c->cnFactor = 0.50;
  1208. X    c->betaStall = 15.0 * pi / 180.0;
  1209. X
  1210. X    c->wingS = 1.0;
  1211. X
  1212. X/*
  1213. X *  Assume 150.0 lbs of weight is fuel and that it burns for 20 seconds.
  1214. X *  That yields a fuel burn rate of 7.5 lbs/second.
  1215. X */
  1216. X
  1217. X    c->emptyWeight = 40.0;
  1218. X    c->maxFuel = 150.0;
  1219. X    c->maxThrust = 791.0;
  1220. X    c->spFuelConsump = 34.134;
  1221. X
  1222. X/*
  1223. X *  Three second arming delay
  1224. X */
  1225. X
  1226. X    c->armDelay = 3.0;
  1227. X
  1228. X    c->groundingPoint.x = 0.0;
  1229. X    c->groundingPoint.y = 0.0;
  1230. X    c->groundingPoint.z = 0.0;
  1231. X
  1232. X    c->viewPoint.x = 0.0;
  1233. X    c->viewPoint.y = 0.0;
  1234. X    c->viewPoint.z = 0.0;
  1235. X
  1236. X    c->crashC = 1.0;
  1237. X
  1238. X    c->muStatic = 0.0;
  1239. X    c->muKinetic = 0.0;
  1240. X    c->muBStatic = 0.0;
  1241. X    c->muBKinetic = 0.0;
  1242. X
  1243. X    c->maxNWDef = 0.0;
  1244. X    c->NWIncr = 0.0;
  1245. X    c->maxNWS = 0.0;
  1246. X    c->gearD1 = 0.0;
  1247. X    c->gearD2 = 0.0;
  1248. X
  1249. X    f = fopen ("aim-9", "r");
  1250. X    c->object = VReadObject(f);
  1251. X    fclose (f);
  1252. X
  1253. X}
  1254. *-*-END-of-./fsim/aim9m.c-*-*
  1255. echo x - ./fsim/bullet
  1256. sed 's/^X//' >./fsim/bullet <<'*-*-END-of-./fsim/bullet-*-*'
  1257. X*a-bullet
  1258. X6 3
  1259. X1 0 0 0
  1260. X2 -0.4 0.5 0
  1261. X3 -19.0 0 0
  1262. X4 -0.4 -0.5 0
  1263. X5 -0.4 0 0.5
  1264. X6 -0.4 0 -0.5
  1265. Xred 4 1 2 3 4
  1266. Xred 4 1 5 3 6
  1267. Xred 4 2 5 4 6
  1268. *-*-END-of-./fsim/bullet-*-*
  1269. echo x - ./fsim/makefile.orig
  1270. sed 's/^X//' >./fsim/makefile.orig <<'*-*-END-of-./fsim/makefile.orig-*-*'
  1271. X#
  1272. X# Makefile for acm;  Riley Rainey, 1990
  1273. X#
  1274. XLDFLAGS = -L../V/lib
  1275. XCFLAGS = -g -I../V/lib -systype bsd43
  1276. X
  1277. XOBFILES = server.o \
  1278. X      pm.o \
  1279. X      flaps.o \
  1280. X      droneCalculations.o\
  1281. X      init.o \
  1282. X      aim9m.o \
  1283. X      m61a1.o \
  1284. X      weapon.o \
  1285. X      newPlayer.o \
  1286. X      newPlane.o \
  1287. X      missile.o \
  1288. X      missileCalculations.o \
  1289. X      update.o \
  1290. X      doEvents.o \
  1291. X      getStick.o \
  1292. X      doViews.o \
  1293. X      doRadar.o \
  1294. X      placeCraft.o \
  1295. X      transpose.o \
  1296. X      doScale.o
  1297. X
  1298. Xall:    acm acms
  1299. X
  1300. Xacm:    acm.o
  1301. X    cc $(CFLAGS) $(LDFLAGS) -o acm acm.o
  1302. X
  1303. Xacms:    $(OBFILES)
  1304. X    cc $(CFLAGS) $(LDFLAGS) -o acms $(OBFILES) -lV -lX11 -lm
  1305. X
  1306. Xclean:
  1307. X    -rm core *.o
  1308. X
  1309. Xclobber:
  1310. X    -rm acm acms *.o core
  1311. X
  1312. Xtar:
  1313. X    tar cv acm acms f16 mig23 aim-9 rwy rwy2 tower mtn bullet
  1314. *-*-END-of-./fsim/makefile.orig-*-*
  1315. echo x - ./fsim/V2tgif.c
  1316. sed 's/^X//' >./fsim/V2tgif.c <<'*-*-END-of-./fsim/V2tgif.c-*-*'
  1317. X#include <stdio.h>
  1318. X#include <Vlib.h>
  1319. X
  1320. X#define INCHES    128
  1321. X
  1322. Xint    horg = 4 * INCHES;
  1323. Xint    vorg = 5 * INCHES;
  1324. Xdouble    scale = ((double) INCHES / 4.0);    /* 4 feet to the inch */
  1325. X
  1326. X#define    XAXIS    1
  1327. X#define YAXIS    2
  1328. X#define ZAXIS    3
  1329. Xint    axis = XAXIS;
  1330. X
  1331. Xextern char * optarg;
  1332. X
  1333. Xmain (argc, argv)
  1334. Xint    argc;
  1335. Xchar     *argv[]; {
  1336. X
  1337. X    VObject    *object;
  1338. X    char    *name;
  1339. X    FILE    *f;
  1340. X    int    c, i, j, k, n;
  1341. X    int    v, h;
  1342. X    VPoint    *q, tmp;
  1343. X    VMatrix     mtx;
  1344. X    VPolygon **p;
  1345. X
  1346. X    while ((c = getopt (argc, argv, "f:xyz")) != EOF) {
  1347. X
  1348. X        switch (c) {
  1349. X
  1350. X        case 'f':
  1351. X            name = optarg;
  1352. X            break;
  1353. X
  1354. X        case 'x':
  1355. X            axis = XAXIS;
  1356. X            break;
  1357. X
  1358. X        case 'y':
  1359. X            axis = YAXIS;
  1360. X            break;
  1361. X
  1362. X        case 'z':
  1363. X            axis = ZAXIS;
  1364. X            break;
  1365. X        }
  1366. X    }
  1367. X
  1368. X    f = fopen (name, "r");
  1369. X    object = VReadObject(f);
  1370. X    fclose (f);
  1371. X
  1372. X    printf ("state(0,6,0,0,0,16,1,4,1,1,0,0,1,0,1,0,1,0,4).\n");
  1373. X
  1374. X    n = object->numPolys;
  1375. X    p = object->polygon;
  1376. X    for (i=0; i<n; ++i) {
  1377. X        printf ("polygon(yellow,%d,[", p[i]->numVtces+1);
  1378. X        for ((k=0, q=p[i]->vertex); k<p[i]->numVtces; (++k, ++q)) {
  1379. X            transform (q, &v, &h);
  1380. X            printf ("%d,%d,", v, h);    
  1381. X        }
  1382. X        transform (p[i]->vertex, &v, &h);
  1383. X        printf ("%d,%d],0,0,1,0).\n", v, h);
  1384. X        ++j;
  1385. X    }
  1386. X
  1387. X    exit (0);
  1388. X}
  1389. X
  1390. Xtransform (p, y, x)
  1391. XVPoint    *p;
  1392. Xint    *y, *x; {
  1393. X
  1394. X    double    dx, dy;
  1395. X
  1396. X    if (axis == XAXIS) {
  1397. X        dx = p->y;
  1398. X        dy = p->z;
  1399. X    }
  1400. X    else if (axis == YAXIS) {
  1401. X        dx = p->x;
  1402. X        dy = p->z;
  1403. X    }
  1404. X    else if (axis == ZAXIS) {
  1405. X        dx = p->x;
  1406. X        dy = p->y;
  1407. X    }
  1408. X
  1409. X    *x = (int) (dx * scale + 0.5) + vorg;
  1410. X    *y = (int) (dy * scale + 0.5) + horg;
  1411. X}
  1412. X    
  1413. *-*-END-of-./fsim/V2tgif.c-*-*
  1414. exit
  1415. -- 
  1416. Riley Rainey            Internet: riley@mips.com
  1417. MIPS Computer Systems        Phone:    +1 214 770-7979
  1418. Dallas, Texas
  1419.  
  1420. dan
  1421. ----------------------------------------------------
  1422. O'Reilly && Associates   argv@sun.com / argv@ora.com
  1423. Opinions expressed reflect those of the author only.
  1424.